
import connector.ConnectorBean;
import connector.ConnectorEvent;
import connector.ConnectorEventListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Lattis
 */
public class Main {

    public static void main(String args[]){
        try {
            ConnectorBean c = new ConnectorBean();
            c.setName("lib");
            c.setPass("lib");
            c.setURL("jdbc:derby://localhost:1527/Library");
            c.addConnectorEventListener(new ConnectorEventListener() {

                public void Connected(ConnectorEvent e) {
                    System.out.println("Connected");
                }

                public void notConnected(ConnectorEvent e) {
                    System.out.println("Disconnected");
                }

                public void ErrorEvent(ConnectorEvent e) {
                    System.out.println("ERROR");
                }

                public void OkEvent(ConnectorEvent e) {
                    System.out.println("OK");
                }
            });
            c.connect();
            ResultSet rs = c.execute("select * from lib.kniha");
            while (rs.next()) {
                System.out.println(rs.getString(2));
            }
            c.insert("delete from kniha where id_kniha = 30005");

        } catch (SQLException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
